// 本文件用于：全局遮罩组件
// 使用时，父级组件需要设置 position
import LoadingIcon from '@/components/loading-icon';
import { RootState } from '@/store';
import { memo } from 'react';
import { useSelector } from 'react-redux';
import styles from './index.module.less';

export default memo(() => {
  const globalMaskInfo = useSelector((state: RootState) => state.global.globalMask);

  return globalMaskInfo.show ? (
    <div className={globalMaskInfo.type === 'fullscreen' ? styles.fullGlobalMask : styles.appMask}>
      <LoadingIcon className={styles.icon} size={26} />
      <span>{globalMaskInfo.text || '努力加载中'}</span>
    </div>
  ) : undefined;
});
